package org.fullhappy.dao;

import java.util.List;
import java.util.logging.Logger;

import javax.persistence.EntityManager;

import org.fullhappy.entity.Category;

public class CategoryDAO extends DAO<Category> {
	public CategoryDAO() {
		super(Category.class);
	}
	public List<Category> findByGalleryId(long galleryId) {
		EntityManager entityManager = EMF.get().createEntityManager();
		List<Category> list1 = null;
		try {
			List<Category> list = entityManager.createQuery(
					" SELECT e FROM " + Category.class.getSimpleName() + " e WHERE e.galleryId = " + galleryId)
					.getResultList();
			list1 = list.subList(0, list.size());
		} catch (Exception e) {
			Logger.getLogger("findAll" + e.getMessage());
		} finally {
			entityManager.close();
		}
		return list1;
	}

}
